cmake_minimum_required (VERSION 3.10)

project(example_brpc)

include(FindProtobuf)
find_package(Protobuf QUIET)
find_package(gRPC CONFIG QUIET)

pkg_check_modules(brpc QUIET brpc)
if(Protobuf_FOUND AND brpc_FOUND)
    message(STATUS "build ${PROJECT_NAME}")

    protobuf_generate_cpp(PROTO_SRC PROTO_HEADERS proto/echo.proto)
    include_directories(${CMAKE_CURRENT_BINARY_DIR})

    aux_source_directory(. DIR_SOURCES)
    add_executable (${PROJECT_NAME} ${DIR_SOURCES} ${PROTO_SRC} ${PROTO_HEADERS})

    target_link_libraries(${PROJECT_NAME} Threads::Threads)
    target_link_libraries(${PROJECT_NAME} ${brpc_LIBRARIES})
    target_link_libraries(${PROJECT_NAME} ${Protobuf_LIBRARIES})
endif()